﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

using QLTTAN.DTO;
namespace QLTTAN.DAL
{
    public class LichThiDAL
    {
        ConnectionData conn;

        public DataRow LichThi_GetInfo(LichThiDTO LT_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 1;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            name[0] = "MaLichThi";
            value[0] = LT_DTO.MaLichThi;

            return conn.GetData("LICHTHI_GETINFO", name, value, Nparameter).Rows[0];
        }

        public DataTable LichThi_Load_MaKhoa(LopHocDTO LH_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 1;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            name[0] = "MaKhoaHoc";
            value[0] = LH_DTO.MaKhoaHoc;

            return conn.GetData("LICHTHI_LOAD", name, value, Nparameter);
        }

        public int LichThi_Insert(LichThiDTO LT_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 5;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            name[0] = "NgayThi";
            value[0] = LT_DTO.NgayThi;
            name[1] = "ThoiGianThi";
            value[1] = LT_DTO.ThoiGianThi;
            name[2] = "MaPhong";
            value[2] = LT_DTO.MaPhong;
            name[3] = "MaLop";
            value[3] = LT_DTO.MaLop;
            name[4] = "GhiChu";
            value[4] = LT_DTO.GhiChu;

            return conn.UpdateData("LICHTHI_INSERT", name, value, Nparameter);
        }

        public int LichThi_Update(LichThiDTO LT_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 6;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            name[0] = "MaLichThi";
            value[0] = LT_DTO.MaLichThi;
            name[1] = "NgayThi";
            value[1] = LT_DTO.NgayThi;
            name[2] = "ThoiGianThi";
            value[2] = LT_DTO.ThoiGianThi;
            name[3] = "MaPhong";
            value[3] = LT_DTO.MaPhong;
            name[4] = "MaLop";
            value[4] = LT_DTO.MaLop;
            name[5] = "GhiChu";
            value[5] = LT_DTO.GhiChu;

            return conn.UpdateData("LICHTHI_UPDATE", name, value, Nparameter);
        }

        public int LichThi_Delete(LichThiDTO LT_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 1;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            name[0] = "MaLichThi";
            value[0] = LT_DTO.MaLichThi;

            return conn.UpdateData("LICHTHI_DELETE", name, value, Nparameter);
        }
    }
}
